using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;
using Box2D.XNA;
namespace TurbaconPhone
{
    class TestState : State
    {
        #region Fields
        #endregion

        #region Properties
        #endregion

        #region Constructors
        public TestState()
        {
            
            Vector2 size = new Vector2(800, 480);
            CreateEdge(new Vector2(), new Vector2(size.X, 0));
            CreateEdge(new Vector2(), new Vector2(0, size.Y));
            CreateEdge(new Vector2(size.X, 0), size);
            CreateEdge(new Vector2(0, size.Y), size); 
            
        }
        #endregion

        #region Update and Draw
        public override void Update(GameTime gametime)
        {       
            base.Update(gametime);
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            //Program.Game.GraphicsDevice.Clear(Color.LimeGreen);
            
            Graphics.Draw();
        }
        #endregion
        private void CreateEdge(Vector2 v1, Vector2 v2)
        {
            BodyDef def = new BodyDef();
            PolygonShape shape = new PolygonShape();
            Body border = Physics.World.CreateBody(def);
            shape.SetAsEdge(v1, v2);
            border.CreateFixture(shape, 0);
            border.SetUserData(null);
        }
        public override void EnterState()
        {
            EnabledGestures = GestureType.Tap | GestureType.FreeDrag;
            base.EnterState();
        }

        public override void HandleTap(GestureSample gesture)
        {
            new Explosion("explosion", gesture.Position);
        }

        public override void HandleFreeDrag(GestureSample gesture)
        {
            new Particle(TurBacon.Content.GetTexture("slice"), gesture.Position, gesture.Delta, 5);
        }
    }
}
